@extends('home.parent')
@section('title','修改资料')
@section('head_js')
@endsection
@section('head_css')
@endsection
@section('content')
<div class="content-wrapper">
<section class="content-header">
	<h1>
		修改资料
		<small></small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
		<li class="active">修改资料</li>
	</ol>
</section>
<style>
.box-body div.testall{border:1px solid #d5d5d5;}
.box-body div.testall div{color:#717171;padding-top:20px;}
.box-body div.testall div label{padding: 6px 15px 0 0;text-align:right;}
.box-body div.testall div input{width:60%;}
.box-body div.testall div button{margin-right:10px;}
.upimg img{width:100px;height:100px;margin-top:-20px;}
.upimg input[type="file"]{display:none;}
.upimg span{margin-left:10px;}
.upimg span#remove,.upimg span#upload{display:none;}
</style>
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-primary">
				<div class="box-body">
					<!--  star-->
					<div class="form-group col-md-12 testall">
						<form class="" action="" method="">
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">用户名：</label>
							<input type="text" class="form-control" name="admin_name" value="{{ isset($data['admin_name'])?$data['admin_name']:'' }}" autocomplete="off" placeholder="用户名" readonly>
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">昵称：</label>
							<input type="text" class="form-control" name="nick_name" value="{{ isset($data['nick_name'])?$data['nick_name']:'' }}" autocomplete="off" placeholder="昵称">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">真实姓名：</label>
							<input type="text" class="form-control" name="real_name" value="{{ isset($data['real_name'])?$data['real_name']:'' }}" autocomplete="off" placeholder="真实姓名">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">头像：</label>
							<div class="form-group upimg">
								<img src="{{ isset($data['head_img'])&&$data['head_img']!='' ? $data['head_img'] : '/images/default.png' }}" id="showImg">
								<span class="btn btn-info" id="look">选择图片</span>
								<span class="btn btn-default" id="remove">移除</span>
								<span class="btn btn-success" id="upload" onclick="uploadImg('optImg','imgpath')">上传</span>
								<span id="newfile"><input type="file" name="optImg" id="optImg" onchange="optchange(this)"></span>
								<input type="hidden" name="head_img" id="imgpath" value="{{ isset($data['head_img'])&&$data['head_img']!='' ? $data['head_img'] : '/images/default.png' }}">
							</div>
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">性别：</label>
							<input type="text" class="form-control" name="sex" value="{{ isset($data['sex'])?$data['sex']:'' }}" autocomplete="off" placeholder="请输入关键词数量">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">公司名称：</label>
							<input type="text" class="form-control" name="cp_name" value="{{ isset($data['cp_name'])?$data['cp_name']:'' }}" autocomplete="off" placeholder="公司名称">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">公司地址：</label>
							<input type="text" class="form-control" name="cp_address" value="{{ isset($data['cp_address'])?$data['cp_address']:'' }}" autocomplete="off" placeholder="公司地址">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">公司行业：</label>
							<input type="text" class="form-control" name="cp_industry" value="{{ isset($data['cp_industry'])?$data['cp_industry']:'' }}" autocomplete="off" placeholder="公司行业">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">手机号：</label>
							<input type="text" class="form-control" name="mobile" value="{{ isset($data['mobile'])?$data['mobile']:'' }}" autocomplete="off" placeholder="手机号">
						</div>
						<div class="form-group col-md-6">
							<label class="col-sm-3 control-label">邮箱：</label>
							<input type="text" class="form-control" name="cp_mail" value="{{ isset($data['cp_mail'])?$data['cp_mail']:'' }}" autocomplete="off" placeholder="邮箱">
						</div>
						<div class="form-group col-md-12">
							<label class="col-sm-1 control-label"></label>
							<button type="button" class="btn btn-info" onclick="dataSubmit()">保 存</button>
							<button type="reset" class="btn btn-default">重 置</button>
						</div>
						</form>
					</div>
					<!--  end-->
				</div>
			</div>
		</div>
	</div>
</section>
</div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/apk.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script type="text/javascript">
/*
保存操作
*/
function dataSubmit(){
	var nick_name=$('input[name="nick_name"]').val();
	var real_name=$('input[name="real_name"]').val();
	var head_img=$('input[name="head_img"]').val();
	var sex=$('input[name="sex"]').val();
	var cp_name=$('input[name="cp_name"]').val();
	var cp_address=$('input[name="cp_address"]').val();
	var cp_industry=$('input[name="cp_industry"]').val();
	var mobile=$('input[name="mobile"]').val();
	var cp_mail=$('input[name="cp_mail"]').val();
	var data={nick_name:nick_name,real_name:real_name,head_img:head_img,sex:sex,cp_name:cp_name,cp_address:cp_address,cp_industry:cp_industry,mobile:mobile,cp_mail:cp_mail};
	var url = "{{URL('admin/personal/info/save')}}";
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
		layer.msg(result.msg,{icon:2});
		return false;
	}else{
		layer.msg("保存成功",{icon:1});
		setInterval(function(){
			history.go(0);
		},"2000");
	}
}
//上传图片到服务器  经过  apk.js  FileTools.php
function uploadImg(file_id,file_val){
	var url = '{{URL('image/single/upload')}}/code';
	var is_ok=uploadImage(file_id,url,file_val,'','');
	if(is_ok!=false){
		$('#upload').css({"display":"none"});
		layer.msg("上传成功",{icon:1});
	}
}
//预览触发上传控件
$('#look').click(function(){$('#optImg').click();});
//上传控件值发生改变替换图片
function optchange(obj){
	$('#remove,#upload').css({"display":"inline-block"});
	var imgSrc=puppet.getObjectURL(obj);
	// console.log(getObjectURL(this.files[0]));
	$('#showImg').attr('src',imgSrc);
}
//移除图片
$('#remove').click(function(){
	var newimg=$('#imgpath').val();
	var oldimg="{{ isset($data['head_img'])&&$data['head_img']!='' ? $data['head_img'] : '/images/default.png' }}";
	$('#newfile').html('<input type="file" name="optImg" id="optImg" onchange="optchange(this)">');
	$('#remove,#upload').css({"display":"none"});
	$('#imgpath').val(oldimg);
	var url="{{URL('image/delete/file')}}";
	// console.log(url);
	if(newimg&&newimg!='/images/default.png'&&newimg!=oldimg){deleteImg(url,newimg);}
	$('#showImg').attr('src',oldimg);
});
</script>
@endsection